#include <asm.h>
#include <regdef.h>
#include <new_inst_test.h>

LEAF(my19_tlti_ex_test)
    .set noreorder
    addiu s0,s0,1
    li    t0,0x800d0000
    li    s2,9
    sw    s2,0(t0)
##clear cause.TI, status,EXL
    mtc0  zero,c0_compare;
    lui   s7,0x0040
    mtc0  s7,c0_status
    nop
    lui   s7,0x0009
# point 1 ---------------
    TEST_TRAP_HAPPEN(tlti,-2,-1,tlti_pc_0);
    TEST_TRAP_HAPPEN(tlti,-213,4,tlti_pc_1);
    TEST_TRAP_HAPPEN(tlti,2,3,tlti_pc_2);
    TEST_TRAP_HAPPEN(tlti,0,3,tlti_pc_3);
    TEST_TRAP_HAPPEN(tlti,-2,0,tlti_pc_4);
# point 2 ------don't happen-----
    TEST_TRAP_NOT_HAPPEN(tlti,0,0,tlti_pc_5);
    TEST_TRAP_NOT_HAPPEN(tlti,1,-1,tlti_pc_6);
    TEST_TRAP_NOT_HAPPEN(tlti,4,2,tlti_pc_7);
    TEST_TRAP_NOT_HAPPEN(tlti,200,-3000,tlti_pc_8);
    TEST_TRAP_NOT_HAPPEN(tlti,0x323,0xffff,tlti_pc_9);



###score ++
    addiu s3, s3, 1
###output (s0<<24)|s3
test:
    beq s0,s3,inst_error
    nop
    addiu s3,s3,1
    j test
    nop
inst_error:
    sll t1, s0, 24
    or t0, t1, s3
    sw t0, 0(s1)
    jr ra
    nop
END(my19_tlti_ex_test)
